#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_gene1.py
# author: 马国鑫
# datetime:2022/4/7 17:51
# software: PyCharm

"""
this is function  description 
"""

# import module your need


"""
    生成器是一个特殊的迭代器
    生成器的创建：
    1、列表推导式
    2、使用yield创建生成器
"""

data_list1 = [x * 2 for x in range(5)]
for value in data_list1:
    print(value, end=' ')
data_list2 = (x * 2 for x in range(5))
# print(data_list2)


value = next(data_list2)
print()
print('---------->', value)

print("*" * 20)


def test():
    return 10


m = test()
print('m=', m)


def test1():
    yield 10  # 创建了一个生成器对象


n = test1()  # 反回了一个生成器对象
value = next(n)
print('--------->', value)
